package fi.hut.soberit.agilefant.reporting.communication;

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;

public class RemoteCommunicationBuilder {

  private String agilefantHostname;
  private String agilefantUser;
  private String agilefantPassword;
  
  public WebResource getResourceForUrl(String relativeUrl) {
    Client c = createClient();
    WebResource res = c.resource(this.agilefantHostname + relativeUrl);
    return res;
  }
  
  public Client createClient() {
    Client c = Client.create();
    c.addFilter(new HTTPBasicAuthFilter(this.agilefantUser,
        this.agilefantPassword));
    return c;
  }
  
  public String getAgilefantHostname() {
    return agilefantHostname;
  }

  public void setAgilefantHostname(String agilefantHostname) {
    this.agilefantHostname = agilefantHostname;
  }

  public String getAgilefantUser() {
    return agilefantUser;
  }

  public void setAgilefantUser(String agilefantUser) {
    this.agilefantUser = agilefantUser;
  }

  public String getAgilefantPassword() {
    return agilefantPassword;
  }

  public void setAgilefantPassword(String agilefantPassword) {
    this.agilefantPassword = agilefantPassword;
  }
  
  public String getBaseURI() {
    return this.agilefantHostname;
  }
}